<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js 随机字母</title>
</head>
<body>

</body>
<script lang="ts">
    /**
     * js 随机生成 小写字母
     * @param len 生成字符串的长度
     * @return {string}
     */
    const setRandomCode = (len) =>{
        const startNumber = 97; // 大写 字母 A ,  小写字母a Unicode 码 为 97
        const endNumber = 122; // 大写的Z的UNicon 为 90 小写的z是122
        const random = (startNumber = 65,endNumber = 90) =>{
            return Math.floor(Math.random() * (endNumber - startNumber)) + startNumber
        };
        let res = '';
        for(let i = 0; i<len;i++){
            res += String.fromCharCode(random(startNumber,endNumber))
        }
        return res;
    }

</script>
</html>
